package com.epic.consumer;

import com.epic.inter.assetmgr.IAsset;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class Application {

    private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");

    public static void main(String[] args) throws Exception{
//        ReferenceConfig<IAsset> reference = new ReferenceConfig<>();
//        reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
//        reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
//        reference.setInterface(IAsset.class);
//        System.out.println("start");
//        IAsset service = reference.get();
//        System.out.println("11");
//        String message = service.testAsset();
//        System.out.println("12");
//        System.out.println(message);
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/applicationContext.xml");
        context.start();
        System.out.println("111");
        IAsset iAsset = (IAsset) context.getBean("demoService");
        System.out.println("222");
        System.out.println(iAsset.testAsset("afa"));
        System.in.read();
    }
}

/**
 * mvn clean package
 * # mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.samples.client.Application exec:java
 * 使用 tomcat 启动 web + dubbo 项目，一次启动
 * Component注解:把普通的POJO 类实例化到spring的IOC容器中,就是定义成<bean id="" class="">
 */